<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('同源再派M')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse" id="data-search">
            <form id="post-form">
                <div class="select-list">
                    <ul>
                        <li>
                            工单主题：<input type="text" name="myMwfTopic"/>
                        </li>
                        <li>
                            工单内容：<input type="text" name="fmContent"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="dimSearch()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="formReset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="col-sm-12 select-table table-striped" id="data-contend">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:src="@{/common/js/common.js}"></script>
<script th:inline="javascript">
    var prefix = ctx + "system/mMailWF/cmnFile";
    $(function () {
        var options = {
            url: prefix + "/waitReplyList",
            sortName: "PkId",
            sortOrder: "desc",
            uniqueId: "PkId",
            modalName: "同源再派M",
            fixedColumns: true,
            fixedNumber: 3,
            firstLoad:false,
            showRefresh: false,
            columns: [{
                checkbox: true
            },
                {field:'PkId',title:'pkid',visible:false},
                {field:'WfId',title:'WfId',visible:false},
                {field:'myMwfNO',title:'工单编号',align:'center',halign:'center'},
                {field:'SpareString',title:'信件来源',align:'center',halign:'center',sortable:true, formatter:function(value,row,index) {
                        return value == '互联网+督查' ? '<span style="color:red;">'+value+'</span>' : value;
                    }},
                {field:'myMwfTopic',title:'工单主题',align:'center',halign:'center',
                    formatter:function (value, row, index,field) {
                        return "<span style='cursor: pointer;' title='"+value+"'>"+value+"</span>"
                    },
                    cellStyle: cellEllipsis
                },
                {field: 'FmContent', title: '工单内容', align: 'center',formatter:function (value, row, index,field) {
                        return "<span style='cursor: pointer;' title='"+value+"'>"+value+"</span>"
                    },
                    cellStyle: cellEllipsis},
                {field:'SeqName',title:'交办次序',align:'center',sortable:true},
                {field:'SortName',title:'性质',align:'center',sortable:true},
                {field:'DealName',title:'办理方式',align:'center',sortable:true},
                {field:'bkLimit',title:'办理期限',align:'center'},
                {field:'SDeptName',title:'派发单位',align:'center',halign:'center',sortable:true},
                {field:'acDate',title:'签收日期',align:'center'},
                {field:'acRemark',title:'备注',align:'center',halign:'center',
                    formatter:function (value, row, index,field) {
                        if(value==undefined){
                            value='';
                        }
                        return "<span style='cursor: pointer;' title='"+value+"'>"+value+"</span>"
                    },
                    cellStyle: cellEllipsis
                },
                {field:'cbackDesc',title:'下级回复',align:'center',sortable:true}]
        };
        $.table.init(options);
    });


    function dimSearch(){
        let myMwfTopic = $("[name='myMwfTopic']").val()
        let fmContent = $("[name='fmContent']").val()
        if(myMwfTopic === '' && fmContent === ''){
            $.modal.msgWarning("请输入搜索条件")
            return
        }else{
            // $.table.search();
            let data = $("#post-form").serializeArray();
            $.ajax({
                url: prefix + "/waitReplyList?pageNum=1&pageSize=10",
                type : "post",
                data: data,
                dataType : "json",
                async : true,
                success : function(res) {
                    if(res.code === 0){
                        //加载数据
                        $('#bootstrap-table').bootstrapTable('load', res).bootstrapTable('checkAll')
                    }

                }
            });
        }
    }

    function formReset(){
        $("[name='myMwfTopic']").val("")
        $("[name='fmContent']").val("")
        $('#bootstrap-table').bootstrapTable('removeAll')
        $('#bootstrap-table').bootstrapTable('uncheckAll')
    }

    
    function submitHandler() {
        let row = $("#bootstrap-table").bootstrapTable('getSelections');
        if(row.length === 0){
            $.modal.msgWarning("请至少选中一条数据")
            return
        }
        $.modal.confirm("确认派发所选的"+row.length+"条工单",function () {
            var url = prefix + "/batchSendToSon?times="+2;
            var width = '60%';
            var height = '60%';
            var config = {
                id: 'dlSendToSon',
                title: '拟办部门',
                width: width,
                height: height,
                url: url,
                callBack: function(index, layero) {
                    var iframeWin = layero.find('iframe')[0];
                    iframeWin.contentWindow.submitHandler(row);
                }
            };
            $.modal.openOptions(config);
        })
    }

</script>
</body>
</html>